package icu.xuyijie.springbootlearning1.chapter1_2.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author 徐一杰
 * @date 2025/02/24 13:46
 * @description 自定义bean的加载条件
 */
public class MyCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        try {
            Class.forName("java.lang.String");
            return true;
        } catch (ClassNotFoundException e) {
            return false;
        }
    }
}
